import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

class GridViewCase extends StatelessWidget {
  const GridViewCase({Key? key}) : super(key: key);

  List<Widget> getChild() {
    return [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map((int index) {
      return Container(
        child: Text(
          '第$index个',
          style: TextStyle(fontSize: 30),
        ),
        color: Colors.blue,
        alignment: Alignment.center,
      );
    }).toList();
  }

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: EdgeInsets.all(10),
      child: GridView(
        gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
            crossAxisCount: 2, mainAxisSpacing: 10, crossAxisSpacing: 10),
        children: getChild(),
      ),
    );
  }
}
